package com.xzq.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
/**
 * 订单实体类
 * @author Adam
 *
 */
@Entity
public class Orders implements Serializable {
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Integer id;
	@ManyToOne(cascade={CascadeType.MERGE},fetch=FetchType.EAGER)
	@JoinColumn(name="user_id")
	private User user;
	@Column
	private Double sumPrice;
	@Column
	private Integer flag;
	@ManyToOne(cascade={CascadeType.MERGE},fetch=FetchType.EAGER)
	@JoinColumn(name="address_id")
	private Address address;
	@ManyToOne(cascade={CascadeType.MERGE},fetch=FetchType.EAGER)
	@JoinColumn(name="os_id")
	private Order_State os;
	@OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
	@JoinColumn(name="orders_id",insertable=true)
	private Set<OrderAndProduct> onps = new HashSet<OrderAndProduct>();
	
	public Integer getFlag() {
		return flag;
	}
	public void setFlag(Integer flag) {
		this.flag = flag;
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public Double getSumPrice() {
		return sumPrice;
	}
	public void setSumPrice(Double sumPrice) {
		this.sumPrice = sumPrice;
	}
	public Address getAddress() {
		return address;
	}
	public void setAddress(Address address) {
		this.address = address;
	}
	public Order_State getOs() {
		return os;
	}
	public void setOs(Order_State os) {
		this.os = os;
	}
	public Set<OrderAndProduct> getOnps() {
		return onps;
	}
	public void setOnps(Set<OrderAndProduct> onps) {
		this.onps = onps;
	}
	public Orders() {
		super();
	}
	public Orders(Integer id, Double sumPrice, Address address) {
		super();
		this.id = id;
		this.sumPrice = sumPrice;
		this.address = address;
	}
	public Orders(Double sumPrice, Address address) {
		super();
		this.sumPrice = sumPrice;
		this.address = address;
	}
	public Orders(Integer id, User user, Double sumPrice, Integer flag) {
		super();
		this.id = id;
		this.user = user;
		this.sumPrice = sumPrice;
		this.flag = flag;
	}
	
}
